package com.yatush.testmodule.web;

import org.springframework.beans.factory.annotation.Autowired;

import springapp.service.ProductManager;

import com.yatush.backstage.web.BaseAction;
import com.yatush.backstage.web.Bean;

public class ToDoAction extends BaseAction {

	@Autowired
	private ProductManager productManager;

	@Override
	protected void loadData(Bean baseBean) {
		ToDoBean bean = (ToDoBean) baseBean;
		bean.setPercentage(20);
		bean.setProducts(this.productManager.getProducts());
	}

	@Override
	protected String saveForm(Bean bean) {
		ToDoBean todoBean = (ToDoBean) bean;
		int increase = todoBean.getPercentage();
		logger.info("Increasing prices by " + increase
				+ "%. Using ToDoAction!!");
		productManager.increasePrice(increase);
		logger.info("returning from PriceIncreaseForm view to "
				+ getSuccessView());
		return getSuccessView();
	}
}
